<?

class DateFormater{
public static function DateParseFromFormat($stFormat, $stData)
{
    $aDataRet = array();
    $aPieces = split('[:/.\ \-]', $stFormat);
    $aDatePart = split('[:/.\ \-]', $stData);
    foreach($aPieces as $key=>$chPiece)    
    {
        switch ($chPiece)
        {
            case 'd':
            case 'j':
                $aDataRet['day'] = $aDatePart[$key];
                break;
                
            case 'F':
            case 'M':
            case 'm':
            case 'n':
                $aDataRet['month'] = $aDatePart[$key];
                break;
                
            case 'o':
            case 'Y':
            case 'y':
                $aDataRet['year'] = $aDatePart[$key];
                break;
            
            case 'g':
            case 'G':
            case 'h':
            case 'H':
                $aDataRet['hour'] = $aDatePart[$key];
                break;    
                
            case 'i':
                $aDataRet['minute'] = $aDatePart[$key];
                break;
                
            case 's':
                $aDataRet['second'] = $aDatePart[$key];
                break;            
        }
        
    }
    return $aDataRet;
}

	public static function ChangeDateFormat($stDate,$stFormatFrom,$stFormatTo){
	  // When PHP 5.3.0 becomes available to me
	  //$date = date_parse_from_format($stFormatFrom,$stDate);
	  //For now I use the function above
	  $date = DateFormater::DateParseFromFormat($stFormatFrom,$stDate);
	  return date($stFormatTo,mktime($date['hour'],
										$date['minute'],
										$date['second'],
										$date['month'],
										$date['day'],
										$date['year']));
	}
}#dateformater.class.php
?>